#include <sdl_class.h>
#include <SDL3/SDL.h>

void primary::SDL_SURFACE_DELETER::operator()(SDL_Surface* p) const noexcept
{
	SDL_DestroySurface(p);
}

void primary::SDL_WINDOW_DELETER::operator()(SDL_Window* p) const noexcept
{
	SDL_DestroyWindow(p);
}

primary::SDL::SDL()
{
	SDL_Init(0);
}

primary::SDL::~SDL()
{
	SDL_Quit();
}

primary::sdlWindow primary::SDL::CreateSDLWindow(int w, int h, const char* title)
{
	return sdlWindow{ SDL_CreateWindow(title,w,h,SDL_WINDOW_RESIZABLE) };
}

primary::sdlSurface primary::SDL::CreateSDLSurface(utl::image& img)
{
	return sdlSurface{ SDL_CreateSurfaceFrom(img.data,img.width,img.height,img.width * img.channel,SDL_PIXELFORMAT_RGBA8888) };
}

primary::sdlRenderer primary::SDL::CreateSDLRenderer(SDL_Window* win)
{
	return sdlRenderer{ SDL_CreateRenderer(win,nullptr,SDL_RENDERER_SOFTWARE) };
}

void primary::SDL_RENDERER_DELETER::operator()(SDL_Renderer* p) const noexcept
{
	SDL_DestroyRenderer(p);
}
